//
//  ViewController.m
//  UI07_homework
//
//  Created by aaaaaa on 16/6/14.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"
#import "GestureUIImageView.h"
#import "SecondViewController.h"

@interface ViewController ()<GestureUIImageViewDelegate>

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = @"First";
    [self createImage];
}

- (void)createImage{
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, (192 + 5) * 2, (108 + 5) * 3)];
    view.center = self.view.center;
    NSMutableArray *imageViewArray = [NSMutableArray arrayWithCapacity:10];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 2; j++) {
            UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"%02d.jpg", i * 2 + j + 1]];
            GestureUIImageView *imageView = [[GestureUIImageView alloc] initWithImage:image];
            imageView.frame = CGRectMake((192 + 5) * j, (108  + 5)* i, 192, 108);
            imageView.delegate = self;
            [view addSubview:imageView];
            [imageView release];
            imageView.tag = 100 + i * 2 + j + 1;
            [imageViewArray addObject:imageView];
        }
    }
    self.imageViewArray = imageViewArray;
    [self.view addSubview:view];
    [view release];
    
}

- (void)nextViewController:(GestureUIImageView *)imageView{
    self.tag = imageView.tag;
    SecondViewController *secondVc = [[SecondViewController alloc] init];
    [self.navigationController pushViewController:secondVc animated:YES];
    [secondVc release];
    
}

//- (IBAction)changeScreenButtonClick:(UIImageView *)sender{
//    SecondViewController *secondVc = [[SecondViewController alloc] init];
//    secondVc.imageViewArray = self.imageViewArray;
//    secondVc.tag = self.tag;
//    
//    UIWindow *window = [UIApplication sharedApplication].delegate.window;
//    window.rootViewController = secondVc;
//}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
